﻿using System;
using System.Collections.Generic;
using System.Linq;
using UtilZ.Dotnet.Ex.Model;

namespace UtilZ.Dotnet.Ex.Base
{
#pragma warning disable 8500

    /// <summary>
    /// 
    /// </summary>
    unsafe public partial class EnumerableEx
    {
        #region char类型

        /// <summary>
        /// 查找char指针中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<char> FindMaxIndex(char* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<char>(null, null, null, null);
            }

            int maxValueIndex = 0;
            char maxValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<char>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找char数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<char> FindMaxIndex(IEnumerable<char> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<char>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<char>(null, null, null, null);
            }

            int maxValueIndex = 0;
            char maxValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<char>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找char数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<char> FindMaxIndex(IEnumerable<char> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<char>(null, null, null, null);
            }

            int end = startIndex + count;
            int maxValueIndex = startIndex;
            char maxValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<char>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找char数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<char> FindMaxIndex(char[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<char>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<char>(null, null, null, null);
            }

            int maxValueIndex = 0;
            char maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<char>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找char数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<char> FindMaxIndex(char[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<char>(null, null, null, null);
            }

            int end = startIndex + count;
            int maxValueIndex = startIndex;
            char maxValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<char>(null, null, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<char> FindMaxIndex(Span<char> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<char>(null, null, null, null);
            }

            int maxValueIndex = 0;
            char maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<char>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<char> FindMaxIndex(SpanZ<char> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<char>(null, null, null, null);
            }

            int maxValueIndex = 0;
            var ptr = arr.DataPtr;
            char maxValue = ptr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<char>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<char> FindMaxIndex(FlexibleArray<char> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<char>(null, null, null, null);
            }

            int maxValueIndex = 0;
            char maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<char>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<char> FindMaxIndex(ValueTypeFlexibleArray<char> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<char>(null, null, null, null);
            }

            int maxValueIndex = 0;
            char maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<char>(null, null, maxValue, maxValueIndex);
        }



        /// <summary>
        /// 查找char指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<char> FindMinIndex(char* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<char>(null, null, null, null);
            }

            int minValueIndex = 0;
            char minValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<char>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找char数组中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<char> FindMinIndex(IEnumerable<char> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<char>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<char>(null, null, null, null);
            }

            int minValueIndex = 0;
            char minValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<char>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找char指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<char> FindMinIndex(IEnumerable<char> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<char>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            char minValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<char>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找char数组中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<char> FindMinIndex(char[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<char>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<char>(null, null, null, null);
            }

            int minValueIndex = 0;
            char minValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<char>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找char指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<char> FindMinIndex(char[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<char>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            char minValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<char>(minValue, minValueIndex, null, null);
        }


        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<char> FindMinIndex(Span<char> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<char>(null, null, null, null);
            }

            int minValueIndex = 0;
            char minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<char>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<char> FindMinIndex(SpanZ<char> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<char>(null, null, null, null);
            }

            int minValueIndex = 0;
            var ptr = arr.DataPtr;
            char minValue = ptr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<char>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<char> FindMinIndex(FlexibleArray<char> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<char>(null, null, null, null);
            }

            int minValueIndex = 0;
            char minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<char>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<char> FindMinIndex(ValueTypeFlexibleArray<char> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<char>(null, null, null, null);
            }

            int minValueIndex = 0;
            char minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<char>(minValue, minValueIndex, null, null);
        }



        /// <summary>
        /// 查找char指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<char> FindMinMaxIndex(char* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<char>(null, null, null, null);
            }

            int minValueIndex = 0;
            char minValue = ptr[0];
            int maxValueIndex = 0;
            char maxValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }

                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<char>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找char数组中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<char> FindMinMaxIndex(IEnumerable<char> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<char>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<char>(null, null, null, null);
            }

            int minValueIndex = 0;
            char minValue = arr.ElementAt(0);
            int maxValueIndex = 0;
            char maxValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }

                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<char>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找char指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<char> FindMinMaxIndex(IEnumerable<char> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<char>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            char minValue = arr.ElementAt(startIndex);
            int maxValueIndex = startIndex;
            char maxValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }

                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<char>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找char数组中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<char> FindMinMaxIndex(char[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<char>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<char>(null, null, null, null);
            }

            int minValueIndex = 0;
            char minValue = arr[0];
            int maxValueIndex = 0;
            char maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<char>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找char指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<char> FindMinMaxIndex(char[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<char>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            char minValue = arr[startIndex];
            int maxValueIndex = startIndex;
            char maxValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<char>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<char> FindMinMaxIndex(Span<char> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<char>(null, null, null, null);
            }

            int minValueIndex = 0;
            char minValue = arr[0];
            int maxValueIndex = 0;
            char maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<char>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<char> FindMinMaxIndex(SpanZ<char> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<char>(null, null, null, null);
            }

            int minValueIndex = 0;
            char minValue = arr[0];
            int maxValueIndex = 0;
            char maxValue = arr[0];
            var ptr = arr.DataPtr;

            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }

                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<char>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<char> FindMinMaxIndex(FlexibleArray<char> arr)
        {
            if (arr == null || arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<char>(null, null, null, null);
            }

            int minValueIndex = 0;
            char minValue = arr[0];
            int maxValueIndex = 0;
            char maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<char>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<char> FindMinMaxIndex(ValueTypeFlexibleArray<char> arr)
        {
            if (arr == null || arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<char>(null, null, null, null);
            }

            int minValueIndex = 0;
            char minValue = arr[0];
            int maxValueIndex = 0;
            char maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<char>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        #endregion


        #region byte类型

        /// <summary>
        /// 查找byte指针中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<byte> FindMaxIndex(byte* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<byte>(null, null, null, null);
            }

            int maxValueIndex = 0;
            byte maxValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<byte>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找byte数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<byte> FindMaxIndex(IEnumerable<byte> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<byte>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<byte>(null, null, null, null);
            }

            int maxValueIndex = 0;
            byte maxValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<byte>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找byte数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<byte> FindMaxIndex(IEnumerable<byte> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<byte>(null, null, null, null);
            }

            int end = startIndex + count;
            int maxValueIndex = startIndex;
            byte maxValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<byte>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找byte数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<byte> FindMaxIndex(byte[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<byte>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<byte>(null, null, null, null);
            }

            int maxValueIndex = 0;
            byte maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<byte>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找byte数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<byte> FindMaxIndex(byte[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<byte>(null, null, null, null);
            }

            int end = startIndex + count;
            int maxValueIndex = startIndex;
            byte maxValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<byte>(null, null, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<byte> FindMaxIndex(Span<byte> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<byte>(null, null, null, null);
            }

            int maxValueIndex = 0;
            byte maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<byte>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<byte> FindMaxIndex(SpanZ<byte> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<byte>(null, null, null, null);
            }

            int maxValueIndex = 0;
            var ptr = arr.DataPtr;
            byte maxValue = ptr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<byte>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<byte> FindMaxIndex(FlexibleArray<byte> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<byte>(null, null, null, null);
            }

            int maxValueIndex = 0;
            byte maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<byte>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<byte> FindMaxIndex(ValueTypeFlexibleArray<byte> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<byte>(null, null, null, null);
            }

            int maxValueIndex = 0;
            byte maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<byte>(null, null, maxValue, maxValueIndex);
        }



        /// <summary>
        /// 查找byte指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<byte> FindMinIndex(byte* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<byte>(null, null, null, null);
            }

            int minValueIndex = 0;
            byte minValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<byte>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找byte数组中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<byte> FindMinIndex(IEnumerable<byte> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<byte>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<byte>(null, null, null, null);
            }

            int minValueIndex = 0;
            byte minValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<byte>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找byte指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<byte> FindMinIndex(IEnumerable<byte> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<byte>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            byte minValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<byte>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找byte数组中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<byte> FindMinIndex(byte[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<byte>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<byte>(null, null, null, null);
            }

            int minValueIndex = 0;
            byte minValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<byte>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找byte指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<byte> FindMinIndex(byte[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<byte>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            byte minValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<byte>(minValue, minValueIndex, null, null);
        }


        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<byte> FindMinIndex(Span<byte> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<byte>(null, null, null, null);
            }

            int minValueIndex = 0;
            byte minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<byte>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<byte> FindMinIndex(SpanZ<byte> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<byte>(null, null, null, null);
            }

            int minValueIndex = 0;
            var ptr = arr.DataPtr;
            byte minValue = ptr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<byte>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<byte> FindMinIndex(FlexibleArray<byte> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<byte>(null, null, null, null);
            }

            int minValueIndex = 0;
            byte minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<byte>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<byte> FindMinIndex(ValueTypeFlexibleArray<byte> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<byte>(null, null, null, null);
            }

            int minValueIndex = 0;
            byte minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<byte>(minValue, minValueIndex, null, null);
        }



        /// <summary>
        /// 查找byte指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<byte> FindMinMaxIndex(byte* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<byte>(null, null, null, null);
            }

            int minValueIndex = 0;
            byte minValue = ptr[0];
            int maxValueIndex = 0;
            byte maxValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }

                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<byte>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找byte数组中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<byte> FindMinMaxIndex(IEnumerable<byte> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<byte>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<byte>(null, null, null, null);
            }

            int minValueIndex = 0;
            byte minValue = arr.ElementAt(0);
            int maxValueIndex = 0;
            byte maxValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }

                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<byte>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找byte指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<byte> FindMinMaxIndex(IEnumerable<byte> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<byte>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            byte minValue = arr.ElementAt(startIndex);
            int maxValueIndex = startIndex;
            byte maxValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }

                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<byte>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找byte数组中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<byte> FindMinMaxIndex(byte[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<byte>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<byte>(null, null, null, null);
            }

            int minValueIndex = 0;
            byte minValue = arr[0];
            int maxValueIndex = 0;
            byte maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<byte>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找byte指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<byte> FindMinMaxIndex(byte[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<byte>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            byte minValue = arr[startIndex];
            int maxValueIndex = startIndex;
            byte maxValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<byte>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<byte> FindMinMaxIndex(Span<byte> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<byte>(null, null, null, null);
            }

            int minValueIndex = 0;
            byte minValue = arr[0];
            int maxValueIndex = 0;
            byte maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<byte>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<byte> FindMinMaxIndex(SpanZ<byte> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<byte>(null, null, null, null);
            }

            int minValueIndex = 0;
            byte minValue = arr[0];
            int maxValueIndex = 0;
            byte maxValue = arr[0];
            var ptr = arr.DataPtr;

            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }

                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<byte>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<byte> FindMinMaxIndex(FlexibleArray<byte> arr)
        {
            if (arr == null || arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<byte>(null, null, null, null);
            }

            int minValueIndex = 0;
            byte minValue = arr[0];
            int maxValueIndex = 0;
            byte maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<byte>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<byte> FindMinMaxIndex(ValueTypeFlexibleArray<byte> arr)
        {
            if (arr == null || arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<byte>(null, null, null, null);
            }

            int minValueIndex = 0;
            byte minValue = arr[0];
            int maxValueIndex = 0;
            byte maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<byte>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        #endregion


        #region sbyte类型

        /// <summary>
        /// 查找sbyte指针中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<sbyte> FindMaxIndex(sbyte* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<sbyte>(null, null, null, null);
            }

            int maxValueIndex = 0;
            sbyte maxValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<sbyte>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找sbyte数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<sbyte> FindMaxIndex(IEnumerable<sbyte> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<sbyte>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<sbyte>(null, null, null, null);
            }

            int maxValueIndex = 0;
            sbyte maxValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<sbyte>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找sbyte数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<sbyte> FindMaxIndex(IEnumerable<sbyte> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<sbyte>(null, null, null, null);
            }

            int end = startIndex + count;
            int maxValueIndex = startIndex;
            sbyte maxValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<sbyte>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找sbyte数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<sbyte> FindMaxIndex(sbyte[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<sbyte>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<sbyte>(null, null, null, null);
            }

            int maxValueIndex = 0;
            sbyte maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<sbyte>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找sbyte数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<sbyte> FindMaxIndex(sbyte[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<sbyte>(null, null, null, null);
            }

            int end = startIndex + count;
            int maxValueIndex = startIndex;
            sbyte maxValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<sbyte>(null, null, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<sbyte> FindMaxIndex(Span<sbyte> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<sbyte>(null, null, null, null);
            }

            int maxValueIndex = 0;
            sbyte maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<sbyte>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<sbyte> FindMaxIndex(SpanZ<sbyte> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<sbyte>(null, null, null, null);
            }

            int maxValueIndex = 0;
            var ptr = arr.DataPtr;
            sbyte maxValue = ptr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<sbyte>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<sbyte> FindMaxIndex(FlexibleArray<sbyte> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<sbyte>(null, null, null, null);
            }

            int maxValueIndex = 0;
            sbyte maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<sbyte>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<sbyte> FindMaxIndex(ValueTypeFlexibleArray<sbyte> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<sbyte>(null, null, null, null);
            }

            int maxValueIndex = 0;
            sbyte maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<sbyte>(null, null, maxValue, maxValueIndex);
        }



        /// <summary>
        /// 查找sbyte指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<sbyte> FindMinIndex(sbyte* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<sbyte>(null, null, null, null);
            }

            int minValueIndex = 0;
            sbyte minValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<sbyte>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找sbyte数组中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<sbyte> FindMinIndex(IEnumerable<sbyte> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<sbyte>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<sbyte>(null, null, null, null);
            }

            int minValueIndex = 0;
            sbyte minValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<sbyte>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找sbyte指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<sbyte> FindMinIndex(IEnumerable<sbyte> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<sbyte>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            sbyte minValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<sbyte>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找sbyte数组中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<sbyte> FindMinIndex(sbyte[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<sbyte>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<sbyte>(null, null, null, null);
            }

            int minValueIndex = 0;
            sbyte minValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<sbyte>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找sbyte指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<sbyte> FindMinIndex(sbyte[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<sbyte>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            sbyte minValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<sbyte>(minValue, minValueIndex, null, null);
        }


        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<sbyte> FindMinIndex(Span<sbyte> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<sbyte>(null, null, null, null);
            }

            int minValueIndex = 0;
            sbyte minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<sbyte>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<sbyte> FindMinIndex(SpanZ<sbyte> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<sbyte>(null, null, null, null);
            }

            int minValueIndex = 0;
            var ptr = arr.DataPtr;
            sbyte minValue = ptr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<sbyte>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<sbyte> FindMinIndex(FlexibleArray<sbyte> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<sbyte>(null, null, null, null);
            }

            int minValueIndex = 0;
            sbyte minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<sbyte>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<sbyte> FindMinIndex(ValueTypeFlexibleArray<sbyte> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<sbyte>(null, null, null, null);
            }

            int minValueIndex = 0;
            sbyte minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<sbyte>(minValue, minValueIndex, null, null);
        }



        /// <summary>
        /// 查找sbyte指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<sbyte> FindMinMaxIndex(sbyte* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<sbyte>(null, null, null, null);
            }

            int minValueIndex = 0;
            sbyte minValue = ptr[0];
            int maxValueIndex = 0;
            sbyte maxValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }

                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<sbyte>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找sbyte数组中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<sbyte> FindMinMaxIndex(IEnumerable<sbyte> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<sbyte>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<sbyte>(null, null, null, null);
            }

            int minValueIndex = 0;
            sbyte minValue = arr.ElementAt(0);
            int maxValueIndex = 0;
            sbyte maxValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }

                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<sbyte>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找sbyte指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<sbyte> FindMinMaxIndex(IEnumerable<sbyte> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<sbyte>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            sbyte minValue = arr.ElementAt(startIndex);
            int maxValueIndex = startIndex;
            sbyte maxValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }

                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<sbyte>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找sbyte数组中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<sbyte> FindMinMaxIndex(sbyte[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<sbyte>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<sbyte>(null, null, null, null);
            }

            int minValueIndex = 0;
            sbyte minValue = arr[0];
            int maxValueIndex = 0;
            sbyte maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<sbyte>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找sbyte指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<sbyte> FindMinMaxIndex(sbyte[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<sbyte>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            sbyte minValue = arr[startIndex];
            int maxValueIndex = startIndex;
            sbyte maxValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<sbyte>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<sbyte> FindMinMaxIndex(Span<sbyte> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<sbyte>(null, null, null, null);
            }

            int minValueIndex = 0;
            sbyte minValue = arr[0];
            int maxValueIndex = 0;
            sbyte maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<sbyte>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<sbyte> FindMinMaxIndex(SpanZ<sbyte> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<sbyte>(null, null, null, null);
            }

            int minValueIndex = 0;
            sbyte minValue = arr[0];
            int maxValueIndex = 0;
            sbyte maxValue = arr[0];
            var ptr = arr.DataPtr;

            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }

                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<sbyte>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<sbyte> FindMinMaxIndex(FlexibleArray<sbyte> arr)
        {
            if (arr == null || arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<sbyte>(null, null, null, null);
            }

            int minValueIndex = 0;
            sbyte minValue = arr[0];
            int maxValueIndex = 0;
            sbyte maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<sbyte>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<sbyte> FindMinMaxIndex(ValueTypeFlexibleArray<sbyte> arr)
        {
            if (arr == null || arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<sbyte>(null, null, null, null);
            }

            int minValueIndex = 0;
            sbyte minValue = arr[0];
            int maxValueIndex = 0;
            sbyte maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<sbyte>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        #endregion


        #region short类型

        /// <summary>
        /// 查找short指针中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<short> FindMaxIndex(short* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<short>(null, null, null, null);
            }

            int maxValueIndex = 0;
            short maxValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<short>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找short数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<short> FindMaxIndex(IEnumerable<short> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<short>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<short>(null, null, null, null);
            }

            int maxValueIndex = 0;
            short maxValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<short>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找short数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<short> FindMaxIndex(IEnumerable<short> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<short>(null, null, null, null);
            }

            int end = startIndex + count;
            int maxValueIndex = startIndex;
            short maxValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<short>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找short数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<short> FindMaxIndex(short[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<short>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<short>(null, null, null, null);
            }

            int maxValueIndex = 0;
            short maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<short>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找short数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<short> FindMaxIndex(short[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<short>(null, null, null, null);
            }

            int end = startIndex + count;
            int maxValueIndex = startIndex;
            short maxValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<short>(null, null, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<short> FindMaxIndex(Span<short> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<short>(null, null, null, null);
            }

            int maxValueIndex = 0;
            short maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<short>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<short> FindMaxIndex(SpanZ<short> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<short>(null, null, null, null);
            }

            int maxValueIndex = 0;
            var ptr = arr.DataPtr;
            short maxValue = ptr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<short>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<short> FindMaxIndex(FlexibleArray<short> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<short>(null, null, null, null);
            }

            int maxValueIndex = 0;
            short maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<short>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<short> FindMaxIndex(ValueTypeFlexibleArray<short> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<short>(null, null, null, null);
            }

            int maxValueIndex = 0;
            short maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<short>(null, null, maxValue, maxValueIndex);
        }



        /// <summary>
        /// 查找short指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<short> FindMinIndex(short* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<short>(null, null, null, null);
            }

            int minValueIndex = 0;
            short minValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<short>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找short数组中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<short> FindMinIndex(IEnumerable<short> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<short>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<short>(null, null, null, null);
            }

            int minValueIndex = 0;
            short minValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<short>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找short指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<short> FindMinIndex(IEnumerable<short> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<short>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            short minValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<short>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找short数组中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<short> FindMinIndex(short[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<short>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<short>(null, null, null, null);
            }

            int minValueIndex = 0;
            short minValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<short>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找short指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<short> FindMinIndex(short[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<short>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            short minValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<short>(minValue, minValueIndex, null, null);
        }


        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<short> FindMinIndex(Span<short> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<short>(null, null, null, null);
            }

            int minValueIndex = 0;
            short minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<short>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<short> FindMinIndex(SpanZ<short> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<short>(null, null, null, null);
            }

            int minValueIndex = 0;
            var ptr = arr.DataPtr;
            short minValue = ptr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<short>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<short> FindMinIndex(FlexibleArray<short> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<short>(null, null, null, null);
            }

            int minValueIndex = 0;
            short minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<short>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<short> FindMinIndex(ValueTypeFlexibleArray<short> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<short>(null, null, null, null);
            }

            int minValueIndex = 0;
            short minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<short>(minValue, minValueIndex, null, null);
        }



        /// <summary>
        /// 查找short指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<short> FindMinMaxIndex(short* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<short>(null, null, null, null);
            }

            int minValueIndex = 0;
            short minValue = ptr[0];
            int maxValueIndex = 0;
            short maxValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }

                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<short>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找short数组中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<short> FindMinMaxIndex(IEnumerable<short> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<short>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<short>(null, null, null, null);
            }

            int minValueIndex = 0;
            short minValue = arr.ElementAt(0);
            int maxValueIndex = 0;
            short maxValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }

                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<short>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找short指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<short> FindMinMaxIndex(IEnumerable<short> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<short>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            short minValue = arr.ElementAt(startIndex);
            int maxValueIndex = startIndex;
            short maxValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }

                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<short>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找short数组中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<short> FindMinMaxIndex(short[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<short>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<short>(null, null, null, null);
            }

            int minValueIndex = 0;
            short minValue = arr[0];
            int maxValueIndex = 0;
            short maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<short>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找short指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<short> FindMinMaxIndex(short[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<short>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            short minValue = arr[startIndex];
            int maxValueIndex = startIndex;
            short maxValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<short>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<short> FindMinMaxIndex(Span<short> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<short>(null, null, null, null);
            }

            int minValueIndex = 0;
            short minValue = arr[0];
            int maxValueIndex = 0;
            short maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<short>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<short> FindMinMaxIndex(SpanZ<short> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<short>(null, null, null, null);
            }

            int minValueIndex = 0;
            short minValue = arr[0];
            int maxValueIndex = 0;
            short maxValue = arr[0];
            var ptr = arr.DataPtr;

            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }

                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<short>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<short> FindMinMaxIndex(FlexibleArray<short> arr)
        {
            if (arr == null || arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<short>(null, null, null, null);
            }

            int minValueIndex = 0;
            short minValue = arr[0];
            int maxValueIndex = 0;
            short maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<short>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<short> FindMinMaxIndex(ValueTypeFlexibleArray<short> arr)
        {
            if (arr == null || arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<short>(null, null, null, null);
            }

            int minValueIndex = 0;
            short minValue = arr[0];
            int maxValueIndex = 0;
            short maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<short>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        #endregion


        #region ushort类型

        /// <summary>
        /// 查找ushort指针中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<ushort> FindMaxIndex(ushort* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<ushort>(null, null, null, null);
            }

            int maxValueIndex = 0;
            ushort maxValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ushort>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找ushort数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ushort> FindMaxIndex(IEnumerable<ushort> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<ushort>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<ushort>(null, null, null, null);
            }

            int maxValueIndex = 0;
            ushort maxValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ushort>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找ushort数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ushort> FindMaxIndex(IEnumerable<ushort> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<ushort>(null, null, null, null);
            }

            int end = startIndex + count;
            int maxValueIndex = startIndex;
            ushort maxValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ushort>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找ushort数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ushort> FindMaxIndex(ushort[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<ushort>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<ushort>(null, null, null, null);
            }

            int maxValueIndex = 0;
            ushort maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ushort>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找ushort数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ushort> FindMaxIndex(ushort[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<ushort>(null, null, null, null);
            }

            int end = startIndex + count;
            int maxValueIndex = startIndex;
            ushort maxValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ushort>(null, null, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ushort> FindMaxIndex(Span<ushort> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<ushort>(null, null, null, null);
            }

            int maxValueIndex = 0;
            ushort maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ushort>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ushort> FindMaxIndex(SpanZ<ushort> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<ushort>(null, null, null, null);
            }

            int maxValueIndex = 0;
            var ptr = arr.DataPtr;
            ushort maxValue = ptr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ushort>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ushort> FindMaxIndex(FlexibleArray<ushort> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<ushort>(null, null, null, null);
            }

            int maxValueIndex = 0;
            ushort maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ushort>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ushort> FindMaxIndex(ValueTypeFlexibleArray<ushort> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<ushort>(null, null, null, null);
            }

            int maxValueIndex = 0;
            ushort maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ushort>(null, null, maxValue, maxValueIndex);
        }



        /// <summary>
        /// 查找ushort指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<ushort> FindMinIndex(ushort* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<ushort>(null, null, null, null);
            }

            int minValueIndex = 0;
            ushort minValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ushort>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找ushort数组中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ushort> FindMinIndex(IEnumerable<ushort> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<ushort>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<ushort>(null, null, null, null);
            }

            int minValueIndex = 0;
            ushort minValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ushort>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找ushort指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ushort> FindMinIndex(IEnumerable<ushort> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<ushort>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            ushort minValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ushort>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找ushort数组中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ushort> FindMinIndex(ushort[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<ushort>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<ushort>(null, null, null, null);
            }

            int minValueIndex = 0;
            ushort minValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ushort>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找ushort指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ushort> FindMinIndex(ushort[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<ushort>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            ushort minValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ushort>(minValue, minValueIndex, null, null);
        }


        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ushort> FindMinIndex(Span<ushort> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<ushort>(null, null, null, null);
            }

            int minValueIndex = 0;
            ushort minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ushort>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ushort> FindMinIndex(SpanZ<ushort> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<ushort>(null, null, null, null);
            }

            int minValueIndex = 0;
            var ptr = arr.DataPtr;
            ushort minValue = ptr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ushort>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ushort> FindMinIndex(FlexibleArray<ushort> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<ushort>(null, null, null, null);
            }

            int minValueIndex = 0;
            ushort minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ushort>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ushort> FindMinIndex(ValueTypeFlexibleArray<ushort> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<ushort>(null, null, null, null);
            }

            int minValueIndex = 0;
            ushort minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ushort>(minValue, minValueIndex, null, null);
        }



        /// <summary>
        /// 查找ushort指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<ushort> FindMinMaxIndex(ushort* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<ushort>(null, null, null, null);
            }

            int minValueIndex = 0;
            ushort minValue = ptr[0];
            int maxValueIndex = 0;
            ushort maxValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }

                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ushort>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找ushort数组中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ushort> FindMinMaxIndex(IEnumerable<ushort> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<ushort>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<ushort>(null, null, null, null);
            }

            int minValueIndex = 0;
            ushort minValue = arr.ElementAt(0);
            int maxValueIndex = 0;
            ushort maxValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }

                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ushort>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找ushort指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ushort> FindMinMaxIndex(IEnumerable<ushort> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<ushort>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            ushort minValue = arr.ElementAt(startIndex);
            int maxValueIndex = startIndex;
            ushort maxValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }

                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ushort>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找ushort数组中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ushort> FindMinMaxIndex(ushort[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<ushort>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<ushort>(null, null, null, null);
            }

            int minValueIndex = 0;
            ushort minValue = arr[0];
            int maxValueIndex = 0;
            ushort maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ushort>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找ushort指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ushort> FindMinMaxIndex(ushort[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<ushort>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            ushort minValue = arr[startIndex];
            int maxValueIndex = startIndex;
            ushort maxValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ushort>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ushort> FindMinMaxIndex(Span<ushort> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<ushort>(null, null, null, null);
            }

            int minValueIndex = 0;
            ushort minValue = arr[0];
            int maxValueIndex = 0;
            ushort maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ushort>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ushort> FindMinMaxIndex(SpanZ<ushort> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<ushort>(null, null, null, null);
            }

            int minValueIndex = 0;
            ushort minValue = arr[0];
            int maxValueIndex = 0;
            ushort maxValue = arr[0];
            var ptr = arr.DataPtr;

            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }

                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ushort>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ushort> FindMinMaxIndex(FlexibleArray<ushort> arr)
        {
            if (arr == null || arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<ushort>(null, null, null, null);
            }

            int minValueIndex = 0;
            ushort minValue = arr[0];
            int maxValueIndex = 0;
            ushort maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ushort>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ushort> FindMinMaxIndex(ValueTypeFlexibleArray<ushort> arr)
        {
            if (arr == null || arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<ushort>(null, null, null, null);
            }

            int minValueIndex = 0;
            ushort minValue = arr[0];
            int maxValueIndex = 0;
            ushort maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ushort>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        #endregion


        #region int类型

        /// <summary>
        /// 查找int指针中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<int> FindMaxIndex(int* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<int>(null, null, null, null);
            }

            int maxValueIndex = 0;
            int maxValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<int>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找int数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<int> FindMaxIndex(IEnumerable<int> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<int>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<int>(null, null, null, null);
            }

            int maxValueIndex = 0;
            int maxValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<int>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找int数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<int> FindMaxIndex(IEnumerable<int> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<int>(null, null, null, null);
            }

            int end = startIndex + count;
            int maxValueIndex = startIndex;
            int maxValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<int>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找int数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<int> FindMaxIndex(int[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<int>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<int>(null, null, null, null);
            }

            int maxValueIndex = 0;
            int maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<int>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找int数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<int> FindMaxIndex(int[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<int>(null, null, null, null);
            }

            int end = startIndex + count;
            int maxValueIndex = startIndex;
            int maxValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<int>(null, null, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<int> FindMaxIndex(Span<int> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<int>(null, null, null, null);
            }

            int maxValueIndex = 0;
            int maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<int>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<int> FindMaxIndex(SpanZ<int> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<int>(null, null, null, null);
            }

            int maxValueIndex = 0;
            var ptr = arr.DataPtr;
            int maxValue = ptr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<int>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<int> FindMaxIndex(FlexibleArray<int> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<int>(null, null, null, null);
            }

            int maxValueIndex = 0;
            int maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<int>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<int> FindMaxIndex(ValueTypeFlexibleArray<int> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<int>(null, null, null, null);
            }

            int maxValueIndex = 0;
            int maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<int>(null, null, maxValue, maxValueIndex);
        }



        /// <summary>
        /// 查找int指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<int> FindMinIndex(int* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<int>(null, null, null, null);
            }

            int minValueIndex = 0;
            int minValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<int>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找int数组中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<int> FindMinIndex(IEnumerable<int> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<int>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<int>(null, null, null, null);
            }

            int minValueIndex = 0;
            int minValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<int>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找int指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<int> FindMinIndex(IEnumerable<int> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<int>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            int minValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<int>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找int数组中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<int> FindMinIndex(int[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<int>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<int>(null, null, null, null);
            }

            int minValueIndex = 0;
            int minValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<int>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找int指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<int> FindMinIndex(int[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<int>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            int minValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<int>(minValue, minValueIndex, null, null);
        }


        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<int> FindMinIndex(Span<int> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<int>(null, null, null, null);
            }

            int minValueIndex = 0;
            int minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<int>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<int> FindMinIndex(SpanZ<int> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<int>(null, null, null, null);
            }

            int minValueIndex = 0;
            var ptr = arr.DataPtr;
            int minValue = ptr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<int>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<int> FindMinIndex(FlexibleArray<int> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<int>(null, null, null, null);
            }

            int minValueIndex = 0;
            int minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<int>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<int> FindMinIndex(ValueTypeFlexibleArray<int> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<int>(null, null, null, null);
            }

            int minValueIndex = 0;
            int minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<int>(minValue, minValueIndex, null, null);
        }



        /// <summary>
        /// 查找int指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<int> FindMinMaxIndex(int* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<int>(null, null, null, null);
            }

            int minValueIndex = 0;
            int minValue = ptr[0];
            int maxValueIndex = 0;
            int maxValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }

                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<int>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找int数组中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<int> FindMinMaxIndex(IEnumerable<int> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<int>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<int>(null, null, null, null);
            }

            int minValueIndex = 0;
            int minValue = arr.ElementAt(0);
            int maxValueIndex = 0;
            int maxValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }

                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<int>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找int指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<int> FindMinMaxIndex(IEnumerable<int> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<int>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            int minValue = arr.ElementAt(startIndex);
            int maxValueIndex = startIndex;
            int maxValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }

                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<int>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找int数组中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<int> FindMinMaxIndex(int[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<int>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<int>(null, null, null, null);
            }

            int minValueIndex = 0;
            int minValue = arr[0];
            int maxValueIndex = 0;
            int maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<int>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找int指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<int> FindMinMaxIndex(int[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<int>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            int minValue = arr[startIndex];
            int maxValueIndex = startIndex;
            int maxValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<int>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<int> FindMinMaxIndex(Span<int> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<int>(null, null, null, null);
            }

            int minValueIndex = 0;
            int minValue = arr[0];
            int maxValueIndex = 0;
            int maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<int>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<int> FindMinMaxIndex(SpanZ<int> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<int>(null, null, null, null);
            }

            int minValueIndex = 0;
            int minValue = arr[0];
            int maxValueIndex = 0;
            int maxValue = arr[0];
            var ptr = arr.DataPtr;

            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }

                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<int>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<int> FindMinMaxIndex(FlexibleArray<int> arr)
        {
            if (arr == null || arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<int>(null, null, null, null);
            }

            int minValueIndex = 0;
            int minValue = arr[0];
            int maxValueIndex = 0;
            int maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<int>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<int> FindMinMaxIndex(ValueTypeFlexibleArray<int> arr)
        {
            if (arr == null || arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<int>(null, null, null, null);
            }

            int minValueIndex = 0;
            int minValue = arr[0];
            int maxValueIndex = 0;
            int maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<int>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        #endregion


        #region uint类型

        /// <summary>
        /// 查找uint指针中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<uint> FindMaxIndex(uint* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<uint>(null, null, null, null);
            }

            int maxValueIndex = 0;
            uint maxValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<uint>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找uint数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<uint> FindMaxIndex(IEnumerable<uint> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<uint>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<uint>(null, null, null, null);
            }

            int maxValueIndex = 0;
            uint maxValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<uint>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找uint数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<uint> FindMaxIndex(IEnumerable<uint> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<uint>(null, null, null, null);
            }

            int end = startIndex + count;
            int maxValueIndex = startIndex;
            uint maxValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<uint>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找uint数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<uint> FindMaxIndex(uint[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<uint>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<uint>(null, null, null, null);
            }

            int maxValueIndex = 0;
            uint maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<uint>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找uint数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<uint> FindMaxIndex(uint[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<uint>(null, null, null, null);
            }

            int end = startIndex + count;
            int maxValueIndex = startIndex;
            uint maxValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<uint>(null, null, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<uint> FindMaxIndex(Span<uint> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<uint>(null, null, null, null);
            }

            int maxValueIndex = 0;
            uint maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<uint>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<uint> FindMaxIndex(SpanZ<uint> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<uint>(null, null, null, null);
            }

            int maxValueIndex = 0;
            var ptr = arr.DataPtr;
            uint maxValue = ptr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<uint>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<uint> FindMaxIndex(FlexibleArray<uint> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<uint>(null, null, null, null);
            }

            int maxValueIndex = 0;
            uint maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<uint>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<uint> FindMaxIndex(ValueTypeFlexibleArray<uint> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<uint>(null, null, null, null);
            }

            int maxValueIndex = 0;
            uint maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<uint>(null, null, maxValue, maxValueIndex);
        }



        /// <summary>
        /// 查找uint指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<uint> FindMinIndex(uint* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<uint>(null, null, null, null);
            }

            int minValueIndex = 0;
            uint minValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<uint>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找uint数组中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<uint> FindMinIndex(IEnumerable<uint> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<uint>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<uint>(null, null, null, null);
            }

            int minValueIndex = 0;
            uint minValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<uint>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找uint指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<uint> FindMinIndex(IEnumerable<uint> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<uint>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            uint minValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<uint>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找uint数组中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<uint> FindMinIndex(uint[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<uint>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<uint>(null, null, null, null);
            }

            int minValueIndex = 0;
            uint minValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<uint>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找uint指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<uint> FindMinIndex(uint[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<uint>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            uint minValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<uint>(minValue, minValueIndex, null, null);
        }


        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<uint> FindMinIndex(Span<uint> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<uint>(null, null, null, null);
            }

            int minValueIndex = 0;
            uint minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<uint>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<uint> FindMinIndex(SpanZ<uint> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<uint>(null, null, null, null);
            }

            int minValueIndex = 0;
            var ptr = arr.DataPtr;
            uint minValue = ptr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<uint>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<uint> FindMinIndex(FlexibleArray<uint> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<uint>(null, null, null, null);
            }

            int minValueIndex = 0;
            uint minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<uint>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<uint> FindMinIndex(ValueTypeFlexibleArray<uint> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<uint>(null, null, null, null);
            }

            int minValueIndex = 0;
            uint minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<uint>(minValue, minValueIndex, null, null);
        }



        /// <summary>
        /// 查找uint指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<uint> FindMinMaxIndex(uint* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<uint>(null, null, null, null);
            }

            int minValueIndex = 0;
            uint minValue = ptr[0];
            int maxValueIndex = 0;
            uint maxValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }

                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<uint>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找uint数组中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<uint> FindMinMaxIndex(IEnumerable<uint> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<uint>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<uint>(null, null, null, null);
            }

            int minValueIndex = 0;
            uint minValue = arr.ElementAt(0);
            int maxValueIndex = 0;
            uint maxValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }

                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<uint>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找uint指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<uint> FindMinMaxIndex(IEnumerable<uint> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<uint>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            uint minValue = arr.ElementAt(startIndex);
            int maxValueIndex = startIndex;
            uint maxValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }

                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<uint>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找uint数组中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<uint> FindMinMaxIndex(uint[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<uint>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<uint>(null, null, null, null);
            }

            int minValueIndex = 0;
            uint minValue = arr[0];
            int maxValueIndex = 0;
            uint maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<uint>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找uint指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<uint> FindMinMaxIndex(uint[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<uint>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            uint minValue = arr[startIndex];
            int maxValueIndex = startIndex;
            uint maxValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<uint>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<uint> FindMinMaxIndex(Span<uint> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<uint>(null, null, null, null);
            }

            int minValueIndex = 0;
            uint minValue = arr[0];
            int maxValueIndex = 0;
            uint maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<uint>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<uint> FindMinMaxIndex(SpanZ<uint> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<uint>(null, null, null, null);
            }

            int minValueIndex = 0;
            uint minValue = arr[0];
            int maxValueIndex = 0;
            uint maxValue = arr[0];
            var ptr = arr.DataPtr;

            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }

                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<uint>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<uint> FindMinMaxIndex(FlexibleArray<uint> arr)
        {
            if (arr == null || arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<uint>(null, null, null, null);
            }

            int minValueIndex = 0;
            uint minValue = arr[0];
            int maxValueIndex = 0;
            uint maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<uint>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<uint> FindMinMaxIndex(ValueTypeFlexibleArray<uint> arr)
        {
            if (arr == null || arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<uint>(null, null, null, null);
            }

            int minValueIndex = 0;
            uint minValue = arr[0];
            int maxValueIndex = 0;
            uint maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<uint>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        #endregion


        #region long类型

        /// <summary>
        /// 查找long指针中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<long> FindMaxIndex(long* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<long>(null, null, null, null);
            }

            int maxValueIndex = 0;
            long maxValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<long>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找long数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<long> FindMaxIndex(IEnumerable<long> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<long>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<long>(null, null, null, null);
            }

            int maxValueIndex = 0;
            long maxValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<long>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找long数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<long> FindMaxIndex(IEnumerable<long> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<long>(null, null, null, null);
            }

            int end = startIndex + count;
            int maxValueIndex = startIndex;
            long maxValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<long>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找long数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<long> FindMaxIndex(long[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<long>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<long>(null, null, null, null);
            }

            int maxValueIndex = 0;
            long maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<long>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找long数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<long> FindMaxIndex(long[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<long>(null, null, null, null);
            }

            int end = startIndex + count;
            int maxValueIndex = startIndex;
            long maxValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<long>(null, null, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<long> FindMaxIndex(Span<long> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<long>(null, null, null, null);
            }

            int maxValueIndex = 0;
            long maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<long>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<long> FindMaxIndex(SpanZ<long> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<long>(null, null, null, null);
            }

            int maxValueIndex = 0;
            var ptr = arr.DataPtr;
            long maxValue = ptr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<long>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<long> FindMaxIndex(FlexibleArray<long> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<long>(null, null, null, null);
            }

            int maxValueIndex = 0;
            long maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<long>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<long> FindMaxIndex(ValueTypeFlexibleArray<long> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<long>(null, null, null, null);
            }

            int maxValueIndex = 0;
            long maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<long>(null, null, maxValue, maxValueIndex);
        }



        /// <summary>
        /// 查找long指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<long> FindMinIndex(long* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<long>(null, null, null, null);
            }

            int minValueIndex = 0;
            long minValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<long>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找long数组中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<long> FindMinIndex(IEnumerable<long> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<long>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<long>(null, null, null, null);
            }

            int minValueIndex = 0;
            long minValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<long>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找long指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<long> FindMinIndex(IEnumerable<long> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<long>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            long minValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<long>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找long数组中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<long> FindMinIndex(long[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<long>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<long>(null, null, null, null);
            }

            int minValueIndex = 0;
            long minValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<long>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找long指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<long> FindMinIndex(long[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<long>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            long minValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<long>(minValue, minValueIndex, null, null);
        }


        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<long> FindMinIndex(Span<long> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<long>(null, null, null, null);
            }

            int minValueIndex = 0;
            long minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<long>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<long> FindMinIndex(SpanZ<long> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<long>(null, null, null, null);
            }

            int minValueIndex = 0;
            var ptr = arr.DataPtr;
            long minValue = ptr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<long>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<long> FindMinIndex(FlexibleArray<long> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<long>(null, null, null, null);
            }

            int minValueIndex = 0;
            long minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<long>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<long> FindMinIndex(ValueTypeFlexibleArray<long> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<long>(null, null, null, null);
            }

            int minValueIndex = 0;
            long minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<long>(minValue, minValueIndex, null, null);
        }



        /// <summary>
        /// 查找long指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<long> FindMinMaxIndex(long* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<long>(null, null, null, null);
            }

            int minValueIndex = 0;
            long minValue = ptr[0];
            int maxValueIndex = 0;
            long maxValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }

                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<long>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找long数组中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<long> FindMinMaxIndex(IEnumerable<long> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<long>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<long>(null, null, null, null);
            }

            int minValueIndex = 0;
            long minValue = arr.ElementAt(0);
            int maxValueIndex = 0;
            long maxValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }

                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<long>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找long指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<long> FindMinMaxIndex(IEnumerable<long> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<long>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            long minValue = arr.ElementAt(startIndex);
            int maxValueIndex = startIndex;
            long maxValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }

                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<long>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找long数组中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<long> FindMinMaxIndex(long[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<long>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<long>(null, null, null, null);
            }

            int minValueIndex = 0;
            long minValue = arr[0];
            int maxValueIndex = 0;
            long maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<long>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找long指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<long> FindMinMaxIndex(long[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<long>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            long minValue = arr[startIndex];
            int maxValueIndex = startIndex;
            long maxValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<long>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<long> FindMinMaxIndex(Span<long> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<long>(null, null, null, null);
            }

            int minValueIndex = 0;
            long minValue = arr[0];
            int maxValueIndex = 0;
            long maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<long>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<long> FindMinMaxIndex(SpanZ<long> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<long>(null, null, null, null);
            }

            int minValueIndex = 0;
            long minValue = arr[0];
            int maxValueIndex = 0;
            long maxValue = arr[0];
            var ptr = arr.DataPtr;

            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }

                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<long>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<long> FindMinMaxIndex(FlexibleArray<long> arr)
        {
            if (arr == null || arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<long>(null, null, null, null);
            }

            int minValueIndex = 0;
            long minValue = arr[0];
            int maxValueIndex = 0;
            long maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<long>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<long> FindMinMaxIndex(ValueTypeFlexibleArray<long> arr)
        {
            if (arr == null || arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<long>(null, null, null, null);
            }

            int minValueIndex = 0;
            long minValue = arr[0];
            int maxValueIndex = 0;
            long maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<long>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        #endregion


        #region ulong类型

        /// <summary>
        /// 查找ulong指针中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<ulong> FindMaxIndex(ulong* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<ulong>(null, null, null, null);
            }

            int maxValueIndex = 0;
            ulong maxValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ulong>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找ulong数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ulong> FindMaxIndex(IEnumerable<ulong> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<ulong>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<ulong>(null, null, null, null);
            }

            int maxValueIndex = 0;
            ulong maxValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ulong>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找ulong数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ulong> FindMaxIndex(IEnumerable<ulong> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<ulong>(null, null, null, null);
            }

            int end = startIndex + count;
            int maxValueIndex = startIndex;
            ulong maxValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ulong>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找ulong数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ulong> FindMaxIndex(ulong[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<ulong>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<ulong>(null, null, null, null);
            }

            int maxValueIndex = 0;
            ulong maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ulong>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找ulong数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ulong> FindMaxIndex(ulong[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<ulong>(null, null, null, null);
            }

            int end = startIndex + count;
            int maxValueIndex = startIndex;
            ulong maxValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ulong>(null, null, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ulong> FindMaxIndex(Span<ulong> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<ulong>(null, null, null, null);
            }

            int maxValueIndex = 0;
            ulong maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ulong>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ulong> FindMaxIndex(SpanZ<ulong> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<ulong>(null, null, null, null);
            }

            int maxValueIndex = 0;
            var ptr = arr.DataPtr;
            ulong maxValue = ptr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ulong>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ulong> FindMaxIndex(FlexibleArray<ulong> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<ulong>(null, null, null, null);
            }

            int maxValueIndex = 0;
            ulong maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ulong>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ulong> FindMaxIndex(ValueTypeFlexibleArray<ulong> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<ulong>(null, null, null, null);
            }

            int maxValueIndex = 0;
            ulong maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ulong>(null, null, maxValue, maxValueIndex);
        }



        /// <summary>
        /// 查找ulong指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<ulong> FindMinIndex(ulong* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<ulong>(null, null, null, null);
            }

            int minValueIndex = 0;
            ulong minValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ulong>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找ulong数组中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ulong> FindMinIndex(IEnumerable<ulong> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<ulong>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<ulong>(null, null, null, null);
            }

            int minValueIndex = 0;
            ulong minValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ulong>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找ulong指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ulong> FindMinIndex(IEnumerable<ulong> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<ulong>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            ulong minValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ulong>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找ulong数组中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ulong> FindMinIndex(ulong[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<ulong>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<ulong>(null, null, null, null);
            }

            int minValueIndex = 0;
            ulong minValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ulong>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找ulong指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ulong> FindMinIndex(ulong[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<ulong>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            ulong minValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ulong>(minValue, minValueIndex, null, null);
        }


        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ulong> FindMinIndex(Span<ulong> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<ulong>(null, null, null, null);
            }

            int minValueIndex = 0;
            ulong minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ulong>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ulong> FindMinIndex(SpanZ<ulong> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<ulong>(null, null, null, null);
            }

            int minValueIndex = 0;
            var ptr = arr.DataPtr;
            ulong minValue = ptr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ulong>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ulong> FindMinIndex(FlexibleArray<ulong> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<ulong>(null, null, null, null);
            }

            int minValueIndex = 0;
            ulong minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ulong>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ulong> FindMinIndex(ValueTypeFlexibleArray<ulong> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<ulong>(null, null, null, null);
            }

            int minValueIndex = 0;
            ulong minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ulong>(minValue, minValueIndex, null, null);
        }



        /// <summary>
        /// 查找ulong指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<ulong> FindMinMaxIndex(ulong* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<ulong>(null, null, null, null);
            }

            int minValueIndex = 0;
            ulong minValue = ptr[0];
            int maxValueIndex = 0;
            ulong maxValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }

                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ulong>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找ulong数组中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ulong> FindMinMaxIndex(IEnumerable<ulong> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<ulong>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<ulong>(null, null, null, null);
            }

            int minValueIndex = 0;
            ulong minValue = arr.ElementAt(0);
            int maxValueIndex = 0;
            ulong maxValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }

                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ulong>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找ulong指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ulong> FindMinMaxIndex(IEnumerable<ulong> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<ulong>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            ulong minValue = arr.ElementAt(startIndex);
            int maxValueIndex = startIndex;
            ulong maxValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }

                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ulong>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找ulong数组中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ulong> FindMinMaxIndex(ulong[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<ulong>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<ulong>(null, null, null, null);
            }

            int minValueIndex = 0;
            ulong minValue = arr[0];
            int maxValueIndex = 0;
            ulong maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ulong>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找ulong指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ulong> FindMinMaxIndex(ulong[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<ulong>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            ulong minValue = arr[startIndex];
            int maxValueIndex = startIndex;
            ulong maxValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ulong>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ulong> FindMinMaxIndex(Span<ulong> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<ulong>(null, null, null, null);
            }

            int minValueIndex = 0;
            ulong minValue = arr[0];
            int maxValueIndex = 0;
            ulong maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ulong>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ulong> FindMinMaxIndex(SpanZ<ulong> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<ulong>(null, null, null, null);
            }

            int minValueIndex = 0;
            ulong minValue = arr[0];
            int maxValueIndex = 0;
            ulong maxValue = arr[0];
            var ptr = arr.DataPtr;

            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }

                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ulong>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ulong> FindMinMaxIndex(FlexibleArray<ulong> arr)
        {
            if (arr == null || arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<ulong>(null, null, null, null);
            }

            int minValueIndex = 0;
            ulong minValue = arr[0];
            int maxValueIndex = 0;
            ulong maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ulong>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<ulong> FindMinMaxIndex(ValueTypeFlexibleArray<ulong> arr)
        {
            if (arr == null || arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<ulong>(null, null, null, null);
            }

            int minValueIndex = 0;
            ulong minValue = arr[0];
            int maxValueIndex = 0;
            ulong maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<ulong>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        #endregion


        #region float类型

        /// <summary>
        /// 查找float指针中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<float> FindMaxIndex(float* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<float>(null, null, null, null);
            }

            int maxValueIndex = 0;
            float maxValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<float>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找float数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<float> FindMaxIndex(IEnumerable<float> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<float>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<float>(null, null, null, null);
            }

            int maxValueIndex = 0;
            float maxValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<float>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找float数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<float> FindMaxIndex(IEnumerable<float> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<float>(null, null, null, null);
            }

            int end = startIndex + count;
            int maxValueIndex = startIndex;
            float maxValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<float>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找float数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<float> FindMaxIndex(float[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<float>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<float>(null, null, null, null);
            }

            int maxValueIndex = 0;
            float maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<float>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找float数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<float> FindMaxIndex(float[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<float>(null, null, null, null);
            }

            int end = startIndex + count;
            int maxValueIndex = startIndex;
            float maxValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<float>(null, null, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<float> FindMaxIndex(Span<float> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<float>(null, null, null, null);
            }

            int maxValueIndex = 0;
            float maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<float>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<float> FindMaxIndex(SpanZ<float> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<float>(null, null, null, null);
            }

            int maxValueIndex = 0;
            var ptr = arr.DataPtr;
            float maxValue = ptr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<float>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<float> FindMaxIndex(FlexibleArray<float> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<float>(null, null, null, null);
            }

            int maxValueIndex = 0;
            float maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<float>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<float> FindMaxIndex(ValueTypeFlexibleArray<float> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<float>(null, null, null, null);
            }

            int maxValueIndex = 0;
            float maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<float>(null, null, maxValue, maxValueIndex);
        }



        /// <summary>
        /// 查找float指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<float> FindMinIndex(float* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<float>(null, null, null, null);
            }

            int minValueIndex = 0;
            float minValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<float>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找float数组中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<float> FindMinIndex(IEnumerable<float> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<float>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<float>(null, null, null, null);
            }

            int minValueIndex = 0;
            float minValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<float>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找float指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<float> FindMinIndex(IEnumerable<float> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<float>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            float minValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<float>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找float数组中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<float> FindMinIndex(float[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<float>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<float>(null, null, null, null);
            }

            int minValueIndex = 0;
            float minValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<float>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找float指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<float> FindMinIndex(float[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<float>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            float minValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<float>(minValue, minValueIndex, null, null);
        }


        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<float> FindMinIndex(Span<float> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<float>(null, null, null, null);
            }

            int minValueIndex = 0;
            float minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<float>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<float> FindMinIndex(SpanZ<float> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<float>(null, null, null, null);
            }

            int minValueIndex = 0;
            var ptr = arr.DataPtr;
            float minValue = ptr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<float>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<float> FindMinIndex(FlexibleArray<float> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<float>(null, null, null, null);
            }

            int minValueIndex = 0;
            float minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<float>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<float> FindMinIndex(ValueTypeFlexibleArray<float> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<float>(null, null, null, null);
            }

            int minValueIndex = 0;
            float minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<float>(minValue, minValueIndex, null, null);
        }



        /// <summary>
        /// 查找float指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<float> FindMinMaxIndex(float* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<float>(null, null, null, null);
            }

            int minValueIndex = 0;
            float minValue = ptr[0];
            int maxValueIndex = 0;
            float maxValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }

                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<float>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找float数组中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<float> FindMinMaxIndex(IEnumerable<float> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<float>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<float>(null, null, null, null);
            }

            int minValueIndex = 0;
            float minValue = arr.ElementAt(0);
            int maxValueIndex = 0;
            float maxValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }

                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<float>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找float指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<float> FindMinMaxIndex(IEnumerable<float> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<float>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            float minValue = arr.ElementAt(startIndex);
            int maxValueIndex = startIndex;
            float maxValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }

                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<float>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找float数组中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<float> FindMinMaxIndex(float[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<float>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<float>(null, null, null, null);
            }

            int minValueIndex = 0;
            float minValue = arr[0];
            int maxValueIndex = 0;
            float maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<float>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找float指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<float> FindMinMaxIndex(float[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<float>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            float minValue = arr[startIndex];
            int maxValueIndex = startIndex;
            float maxValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<float>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<float> FindMinMaxIndex(Span<float> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<float>(null, null, null, null);
            }

            int minValueIndex = 0;
            float minValue = arr[0];
            int maxValueIndex = 0;
            float maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<float>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<float> FindMinMaxIndex(SpanZ<float> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<float>(null, null, null, null);
            }

            int minValueIndex = 0;
            float minValue = arr[0];
            int maxValueIndex = 0;
            float maxValue = arr[0];
            var ptr = arr.DataPtr;

            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }

                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<float>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<float> FindMinMaxIndex(FlexibleArray<float> arr)
        {
            if (arr == null || arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<float>(null, null, null, null);
            }

            int minValueIndex = 0;
            float minValue = arr[0];
            int maxValueIndex = 0;
            float maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<float>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<float> FindMinMaxIndex(ValueTypeFlexibleArray<float> arr)
        {
            if (arr == null || arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<float>(null, null, null, null);
            }

            int minValueIndex = 0;
            float minValue = arr[0];
            int maxValueIndex = 0;
            float maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<float>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        #endregion


        #region double类型

        /// <summary>
        /// 查找double指针中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<double> FindMaxIndex(double* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<double>(null, null, null, null);
            }

            int maxValueIndex = 0;
            double maxValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<double>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找double数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<double> FindMaxIndex(IEnumerable<double> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<double>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<double>(null, null, null, null);
            }

            int maxValueIndex = 0;
            double maxValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<double>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找double数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<double> FindMaxIndex(IEnumerable<double> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<double>(null, null, null, null);
            }

            int end = startIndex + count;
            int maxValueIndex = startIndex;
            double maxValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<double>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找double数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<double> FindMaxIndex(double[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<double>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<double>(null, null, null, null);
            }

            int maxValueIndex = 0;
            double maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<double>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找double数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<double> FindMaxIndex(double[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<double>(null, null, null, null);
            }

            int end = startIndex + count;
            int maxValueIndex = startIndex;
            double maxValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<double>(null, null, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<double> FindMaxIndex(Span<double> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<double>(null, null, null, null);
            }

            int maxValueIndex = 0;
            double maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<double>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<double> FindMaxIndex(SpanZ<double> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<double>(null, null, null, null);
            }

            int maxValueIndex = 0;
            var ptr = arr.DataPtr;
            double maxValue = ptr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<double>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<double> FindMaxIndex(FlexibleArray<double> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<double>(null, null, null, null);
            }

            int maxValueIndex = 0;
            double maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<double>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<double> FindMaxIndex(ValueTypeFlexibleArray<double> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<double>(null, null, null, null);
            }

            int maxValueIndex = 0;
            double maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<double>(null, null, maxValue, maxValueIndex);
        }



        /// <summary>
        /// 查找double指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<double> FindMinIndex(double* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<double>(null, null, null, null);
            }

            int minValueIndex = 0;
            double minValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<double>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找double数组中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<double> FindMinIndex(IEnumerable<double> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<double>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<double>(null, null, null, null);
            }

            int minValueIndex = 0;
            double minValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<double>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找double指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<double> FindMinIndex(IEnumerable<double> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<double>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            double minValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<double>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找double数组中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<double> FindMinIndex(double[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<double>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<double>(null, null, null, null);
            }

            int minValueIndex = 0;
            double minValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<double>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找double指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<double> FindMinIndex(double[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<double>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            double minValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<double>(minValue, minValueIndex, null, null);
        }


        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<double> FindMinIndex(Span<double> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<double>(null, null, null, null);
            }

            int minValueIndex = 0;
            double minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<double>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<double> FindMinIndex(SpanZ<double> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<double>(null, null, null, null);
            }

            int minValueIndex = 0;
            var ptr = arr.DataPtr;
            double minValue = ptr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<double>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<double> FindMinIndex(FlexibleArray<double> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<double>(null, null, null, null);
            }

            int minValueIndex = 0;
            double minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<double>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<double> FindMinIndex(ValueTypeFlexibleArray<double> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<double>(null, null, null, null);
            }

            int minValueIndex = 0;
            double minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<double>(minValue, minValueIndex, null, null);
        }



        /// <summary>
        /// 查找double指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<double> FindMinMaxIndex(double* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<double>(null, null, null, null);
            }

            int minValueIndex = 0;
            double minValue = ptr[0];
            int maxValueIndex = 0;
            double maxValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }

                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<double>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找double数组中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<double> FindMinMaxIndex(IEnumerable<double> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<double>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<double>(null, null, null, null);
            }

            int minValueIndex = 0;
            double minValue = arr.ElementAt(0);
            int maxValueIndex = 0;
            double maxValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }

                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<double>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找double指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<double> FindMinMaxIndex(IEnumerable<double> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<double>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            double minValue = arr.ElementAt(startIndex);
            int maxValueIndex = startIndex;
            double maxValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }

                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<double>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找double数组中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<double> FindMinMaxIndex(double[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<double>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<double>(null, null, null, null);
            }

            int minValueIndex = 0;
            double minValue = arr[0];
            int maxValueIndex = 0;
            double maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<double>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找double指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<double> FindMinMaxIndex(double[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<double>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            double minValue = arr[startIndex];
            int maxValueIndex = startIndex;
            double maxValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<double>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<double> FindMinMaxIndex(Span<double> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<double>(null, null, null, null);
            }

            int minValueIndex = 0;
            double minValue = arr[0];
            int maxValueIndex = 0;
            double maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<double>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<double> FindMinMaxIndex(SpanZ<double> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<double>(null, null, null, null);
            }

            int minValueIndex = 0;
            double minValue = arr[0];
            int maxValueIndex = 0;
            double maxValue = arr[0];
            var ptr = arr.DataPtr;

            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }

                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<double>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<double> FindMinMaxIndex(FlexibleArray<double> arr)
        {
            if (arr == null || arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<double>(null, null, null, null);
            }

            int minValueIndex = 0;
            double minValue = arr[0];
            int maxValueIndex = 0;
            double maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<double>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<double> FindMinMaxIndex(ValueTypeFlexibleArray<double> arr)
        {
            if (arr == null || arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<double>(null, null, null, null);
            }

            int minValueIndex = 0;
            double minValue = arr[0];
            int maxValueIndex = 0;
            double maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<double>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        #endregion


        #region decimal类型

        /// <summary>
        /// 查找decimal指针中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<decimal> FindMaxIndex(decimal* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<decimal>(null, null, null, null);
            }

            int maxValueIndex = 0;
            decimal maxValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<decimal>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找decimal数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<decimal> FindMaxIndex(IEnumerable<decimal> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<decimal>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<decimal>(null, null, null, null);
            }

            int maxValueIndex = 0;
            decimal maxValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<decimal>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找decimal数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<decimal> FindMaxIndex(IEnumerable<decimal> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<decimal>(null, null, null, null);
            }

            int end = startIndex + count;
            int maxValueIndex = startIndex;
            decimal maxValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<decimal>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找decimal数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<decimal> FindMaxIndex(decimal[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<decimal>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<decimal>(null, null, null, null);
            }

            int maxValueIndex = 0;
            decimal maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<decimal>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找decimal数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<decimal> FindMaxIndex(decimal[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<decimal>(null, null, null, null);
            }

            int end = startIndex + count;
            int maxValueIndex = startIndex;
            decimal maxValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<decimal>(null, null, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<decimal> FindMaxIndex(Span<decimal> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<decimal>(null, null, null, null);
            }

            int maxValueIndex = 0;
            decimal maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<decimal>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<decimal> FindMaxIndex(SpanZ<decimal> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<decimal>(null, null, null, null);
            }

            int maxValueIndex = 0;
            var ptr = arr.DataPtr;
            decimal maxValue = ptr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<decimal>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<decimal> FindMaxIndex(FlexibleArray<decimal> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<decimal>(null, null, null, null);
            }

            int maxValueIndex = 0;
            decimal maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<decimal>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<decimal> FindMaxIndex(ValueTypeFlexibleArray<decimal> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<decimal>(null, null, null, null);
            }

            int maxValueIndex = 0;
            decimal maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<decimal>(null, null, maxValue, maxValueIndex);
        }



        /// <summary>
        /// 查找decimal指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<decimal> FindMinIndex(decimal* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<decimal>(null, null, null, null);
            }

            int minValueIndex = 0;
            decimal minValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<decimal>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找decimal数组中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<decimal> FindMinIndex(IEnumerable<decimal> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<decimal>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<decimal>(null, null, null, null);
            }

            int minValueIndex = 0;
            decimal minValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<decimal>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找decimal指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<decimal> FindMinIndex(IEnumerable<decimal> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<decimal>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            decimal minValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<decimal>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找decimal数组中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<decimal> FindMinIndex(decimal[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<decimal>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<decimal>(null, null, null, null);
            }

            int minValueIndex = 0;
            decimal minValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<decimal>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找decimal指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<decimal> FindMinIndex(decimal[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<decimal>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            decimal minValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<decimal>(minValue, minValueIndex, null, null);
        }


        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<decimal> FindMinIndex(Span<decimal> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<decimal>(null, null, null, null);
            }

            int minValueIndex = 0;
            decimal minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<decimal>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<decimal> FindMinIndex(SpanZ<decimal> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<decimal>(null, null, null, null);
            }

            int minValueIndex = 0;
            var ptr = arr.DataPtr;
            decimal minValue = ptr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<decimal>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<decimal> FindMinIndex(FlexibleArray<decimal> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<decimal>(null, null, null, null);
            }

            int minValueIndex = 0;
            decimal minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<decimal>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<decimal> FindMinIndex(ValueTypeFlexibleArray<decimal> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<decimal>(null, null, null, null);
            }

            int minValueIndex = 0;
            decimal minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<decimal>(minValue, minValueIndex, null, null);
        }



        /// <summary>
        /// 查找decimal指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<decimal> FindMinMaxIndex(decimal* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<decimal>(null, null, null, null);
            }

            int minValueIndex = 0;
            decimal minValue = ptr[0];
            int maxValueIndex = 0;
            decimal maxValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }

                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<decimal>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找decimal数组中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<decimal> FindMinMaxIndex(IEnumerable<decimal> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<decimal>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<decimal>(null, null, null, null);
            }

            int minValueIndex = 0;
            decimal minValue = arr.ElementAt(0);
            int maxValueIndex = 0;
            decimal maxValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }

                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<decimal>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找decimal指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<decimal> FindMinMaxIndex(IEnumerable<decimal> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<decimal>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            decimal minValue = arr.ElementAt(startIndex);
            int maxValueIndex = startIndex;
            decimal maxValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }

                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<decimal>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找decimal数组中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<decimal> FindMinMaxIndex(decimal[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<decimal>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<decimal>(null, null, null, null);
            }

            int minValueIndex = 0;
            decimal minValue = arr[0];
            int maxValueIndex = 0;
            decimal maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<decimal>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找decimal指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<decimal> FindMinMaxIndex(decimal[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<decimal>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            decimal minValue = arr[startIndex];
            int maxValueIndex = startIndex;
            decimal maxValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<decimal>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<decimal> FindMinMaxIndex(Span<decimal> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<decimal>(null, null, null, null);
            }

            int minValueIndex = 0;
            decimal minValue = arr[0];
            int maxValueIndex = 0;
            decimal maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<decimal>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<decimal> FindMinMaxIndex(SpanZ<decimal> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<decimal>(null, null, null, null);
            }

            int minValueIndex = 0;
            decimal minValue = arr[0];
            int maxValueIndex = 0;
            decimal maxValue = arr[0];
            var ptr = arr.DataPtr;

            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }

                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<decimal>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<decimal> FindMinMaxIndex(FlexibleArray<decimal> arr)
        {
            if (arr == null || arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<decimal>(null, null, null, null);
            }

            int minValueIndex = 0;
            decimal minValue = arr[0];
            int maxValueIndex = 0;
            decimal maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<decimal>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<decimal> FindMinMaxIndex(ValueTypeFlexibleArray<decimal> arr)
        {
            if (arr == null || arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<decimal>(null, null, null, null);
            }

            int minValueIndex = 0;
            decimal minValue = arr[0];
            int maxValueIndex = 0;
            decimal maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<decimal>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        #endregion


        #region DateTime类型

        /// <summary>
        /// 查找DateTime指针中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<DateTime> FindMaxIndex(DateTime* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<DateTime>(null, null, null, null);
            }

            int maxValueIndex = 0;
            DateTime maxValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<DateTime>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找DateTime数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<DateTime> FindMaxIndex(IEnumerable<DateTime> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<DateTime>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<DateTime>(null, null, null, null);
            }

            int maxValueIndex = 0;
            DateTime maxValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<DateTime>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找DateTime数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<DateTime> FindMaxIndex(IEnumerable<DateTime> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<DateTime>(null, null, null, null);
            }

            int end = startIndex + count;
            int maxValueIndex = startIndex;
            DateTime maxValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<DateTime>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找DateTime数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<DateTime> FindMaxIndex(DateTime[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<DateTime>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<DateTime>(null, null, null, null);
            }

            int maxValueIndex = 0;
            DateTime maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<DateTime>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找DateTime数组中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<DateTime> FindMaxIndex(DateTime[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<DateTime>(null, null, null, null);
            }

            int end = startIndex + count;
            int maxValueIndex = startIndex;
            DateTime maxValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<DateTime>(null, null, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<DateTime> FindMaxIndex(Span<DateTime> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<DateTime>(null, null, null, null);
            }

            int maxValueIndex = 0;
            DateTime maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<DateTime>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<DateTime> FindMaxIndex(SpanZ<DateTime> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<DateTime>(null, null, null, null);
            }

            int maxValueIndex = 0;
            var ptr = arr.DataPtr;
            DateTime maxValue = ptr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<DateTime>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<DateTime> FindMaxIndex(FlexibleArray<DateTime> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<DateTime>(null, null, null, null);
            }

            int maxValueIndex = 0;
            DateTime maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<DateTime>(null, null, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大值与最大值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<DateTime> FindMaxIndex(ValueTypeFlexibleArray<DateTime> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<DateTime>(null, null, null, null);
            }

            int maxValueIndex = 0;
            DateTime maxValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<DateTime>(null, null, maxValue, maxValueIndex);
        }



        /// <summary>
        /// 查找DateTime指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<DateTime> FindMinIndex(DateTime* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<DateTime>(null, null, null, null);
            }

            int minValueIndex = 0;
            DateTime minValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<DateTime>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找DateTime数组中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<DateTime> FindMinIndex(IEnumerable<DateTime> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<DateTime>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<DateTime>(null, null, null, null);
            }

            int minValueIndex = 0;
            DateTime minValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<DateTime>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找DateTime指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<DateTime> FindMinIndex(IEnumerable<DateTime> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<DateTime>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            DateTime minValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<DateTime>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找DateTime数组中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<DateTime> FindMinIndex(DateTime[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<DateTime>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<DateTime>(null, null, null, null);
            }

            int minValueIndex = 0;
            DateTime minValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<DateTime>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找DateTime指针中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<DateTime> FindMinIndex(DateTime[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<DateTime>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            DateTime minValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<DateTime>(minValue, minValueIndex, null, null);
        }


        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<DateTime> FindMinIndex(Span<DateTime> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<DateTime>(null, null, null, null);
            }

            int minValueIndex = 0;
            DateTime minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<DateTime>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<DateTime> FindMinIndex(SpanZ<DateTime> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<DateTime>(null, null, null, null);
            }

            int minValueIndex = 0;
            var ptr = arr.DataPtr;
            DateTime minValue = ptr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<DateTime>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<DateTime> FindMinIndex(FlexibleArray<DateTime> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<DateTime>(null, null, null, null);
            }

            int minValueIndex = 0;
            DateTime minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<DateTime>(minValue, minValueIndex, null, null);
        }

        /// <summary>
        /// 查找Span中最小值与最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<DateTime> FindMinIndex(ValueTypeFlexibleArray<DateTime> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<DateTime>(null, null, null, null);
            }

            int minValueIndex = 0;
            DateTime minValue = arr[0];
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<DateTime>(minValue, minValueIndex, null, null);
        }



        /// <summary>
        /// 查找DateTime指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="ptr">数据指针</param>
        /// <param name="length">数据长度</param>
        /// <returns>结果</returns>
        unsafe public static MaxMinValueIndexInfo<DateTime> FindMinMaxIndex(DateTime* ptr, int length)
        {
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<DateTime>(null, null, null, null);
            }

            int minValueIndex = 0;
            DateTime minValue = ptr[0];
            int maxValueIndex = 0;
            DateTime maxValue = ptr[0];

            for (int i = 1; i < length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }

                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<DateTime>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找DateTime数组中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<DateTime> FindMinMaxIndex(IEnumerable<DateTime> arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<DateTime>(null, null, null, null);
            }

            int length = arr.Count();
            if (length < 1)
            {
                return new MaxMinValueIndexInfo<DateTime>(null, null, null, null);
            }

            int minValueIndex = 0;
            DateTime minValue = arr.ElementAt(0);
            int maxValueIndex = 0;
            DateTime maxValue = arr.ElementAt(0);

            for (int i = 1; i < length; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }

                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<DateTime>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找DateTime指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<DateTime> FindMinMaxIndex(IEnumerable<DateTime> arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<DateTime>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            DateTime minValue = arr.ElementAt(startIndex);
            int maxValueIndex = startIndex;
            DateTime maxValue = arr.ElementAt(startIndex);

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr.ElementAt(i) < minValue)
                {
                    minValue = arr.ElementAt(i);
                    minValueIndex = i;
                }

                if (arr.ElementAt(i) > maxValue)
                {
                    maxValue = arr.ElementAt(i);
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<DateTime>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找DateTime数组中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<DateTime> FindMinMaxIndex(DateTime[] arr)
        {
            if (arr == null)
            {
                return new MaxMinValueIndexInfo<DateTime>(null, null, null, null);
            }

            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<DateTime>(null, null, null, null);
            }

            int minValueIndex = 0;
            DateTime minValue = arr[0];
            int maxValueIndex = 0;
            DateTime maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<DateTime>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找DateTime指针中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="count">查找的数据个数</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<DateTime> FindMinMaxIndex(DateTime[] arr, int startIndex, int count)
        {
            if (arr == null || count < 1)
            {
                return new MaxMinValueIndexInfo<DateTime>(null, null, null, null);
            }

            int end = startIndex + count;
            int minValueIndex = startIndex;
            DateTime minValue = arr[startIndex];
            int maxValueIndex = startIndex;
            DateTime maxValue = arr[startIndex];

            for (int i = startIndex + 1; i < end; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<DateTime>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<DateTime> FindMinMaxIndex(Span<DateTime> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<DateTime>(null, null, null, null);
            }

            int minValueIndex = 0;
            DateTime minValue = arr[0];
            int maxValueIndex = 0;
            DateTime maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<DateTime>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<DateTime> FindMinMaxIndex(SpanZ<DateTime> arr)
        {
            if (arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<DateTime>(null, null, null, null);
            }

            int minValueIndex = 0;
            DateTime minValue = arr[0];
            int maxValueIndex = 0;
            DateTime maxValue = arr[0];
            var ptr = arr.DataPtr;

            for (int i = 1; i < arr.Length; i++)
            {
                if (ptr[i] < minValue)
                {
                    minValue = ptr[i];
                    minValueIndex = i;
                }

                if (ptr[i] > maxValue)
                {
                    maxValue = ptr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<DateTime>(minValue, minValueIndex, maxValue, maxValueIndex);
        }


        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<DateTime> FindMinMaxIndex(FlexibleArray<DateTime> arr)
        {
            if (arr == null || arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<DateTime>(null, null, null, null);
            }

            int minValueIndex = 0;
            DateTime minValue = arr[0];
            int maxValueIndex = 0;
            DateTime maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<DateTime>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        /// <summary>
        /// 查找Span中最大最小值与最大最小值首次出现的索引
        /// </summary>
        /// <param name="arr">数据数组</param>
        /// <returns>结果</returns>
        public static MaxMinValueIndexInfo<DateTime> FindMinMaxIndex(ValueTypeFlexibleArray<DateTime> arr)
        {
            if (arr == null || arr.Length < 1)
            {
                return new MaxMinValueIndexInfo<DateTime>(null, null, null, null);
            }

            int minValueIndex = 0;
            DateTime minValue = arr[0];
            int maxValueIndex = 0;
            DateTime maxValue = arr[0];

            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] < minValue)
                {
                    minValue = arr[i];
                    minValueIndex = i;
                }

                if (arr[i] > maxValue)
                {
                    maxValue = arr[i];
                    maxValueIndex = i;
                }
            }

            return new MaxMinValueIndexInfo<DateTime>(minValue, minValueIndex, maxValue, maxValueIndex);
        }

        #endregion
    }
}
